package main

import (
	// "auusoft/AuuWiki/controllers"
	// "auusoft/AuuWiki/controllers/userctr"
	// "fmt"
	"fmt"
	"github.com/astaxie/beego"
	"strconv"
	//"jiabo/appframework/libs/autoNumber"
	"jiabo/appframework/controllers"
	"jiabo/appframework/libs/common"
)

func main() {
	beego.SessionOn = true
	beego.SessionName = "AuuTaskListId"

	//读配置文件，session的保存期限
	if ar, err := beego.AppConfig.Int("sessiongcmaxlifetime"); err == nil && ar != 0 {
		int64val, _ := strconv.ParseInt(strconv.Itoa(ar), 10, 64)
		beego.SessionGCMaxLifetime = int64val
		fmt.Println("Read AppConfig file: Session max lift time is", int64val)
	} else {
		//如果读取失败，默认1200s，现在感觉这个时间不准呢
		fmt.Println("Read AppConfig file: Session max lift time is 1200")
		beego.SessionGCMaxLifetime = 1200
	}

	// //注册controller
	beego.RegisterController("/", &controllers.MainController{})
	beego.RegisterController("/message", &controllers.MessageController{})
	beego.RegisterController("/login", &controllers.LoginController{})
	beego.RegisterController("/register", &controllers.RegisterController{})
	beego.RegisterController("/myorg", &controllers.OrgController{})
	beego.RegisterController("/createorg", &controllers.CreateOrg{})
	// beego.RegisterController("/userctr/deluser", &userctr.UserDeleteController{})
	// beego.RegisterController("/userctr/cp", &userctr.ChangePasswordController{})

	fmt.Println("JiaBo Task Management service is listening on port:", beego.HttpPort)
	beego.Run()
	// var dep department.Department
	// dep, _ = department.GetDepartmentByName("测")
	a := common.Substr("123456789", 0, 5)
	//a, _ := autoNumber.GetFormattedNumber("department")
	fmt.Println(a)

}
